<?php

namespace common\models\user;

use Yii;

/**
 * This is the model class for table "{{%user_meta}}".
 *
 * @property int $id
 * @property string $nickname
 * @property string $mobile
 * @property string $email
 * @property string $avatar
 * @property string $cover
 * @property int $gender
 * @property string $signature
 * @property string $birthday
 * @property string $location
 * @property string $created_at
 * @property string $updated_at
 */
class UserMeta extends \common\db\ActiveRecord {

    /**
     * @inheritdoc
     */
    public static function tableName() {
        return '{{%user_meta}}';
    }

    /**
     * @inheritdoc
     */
    public function rules() {
        return [
            [['id', 'gender', 'created_at', 'updated_at'], 'integer'],
            [['cover'], 'string', 'max' => 255],
            [['signature'], 'string', 'max' => 128],
            [['location'], 'string', 'max' => 64],
            [['birthday'], 'safe'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'cover' => '空间封面',
            'gender' => '性别',
            'signature' => '个人签名',
            'birthday' => '出生日期',
            'location' => '位置',
            'created_at' => '注册时间',
            'updated_at' => '最后修改时间',
        ];
    }

    public function getUser() {
        return $this->hasOne(Yii::$app->user->identityClass, ['id' => 'id']);
    }

    public function getAccount() {
        return $this->hasOne(User::className(), ['id' => 'id']);
    }

    public function getMember() {
        return $this->hasOne(\common\models\member\Member::className(), ['user_id' => 'id']);
    }

}
